package edu.westga.cs3202.sokoban;

import java.awt.event.*;

/**
 * GUIObserver tells the gameController when certain keys are pressed.
 * 
 * @author Lewis Williams
 * @version 2011.2.17
 */
public class GUIObserver extends KeyAdapter{
	private Controller gameController;
	
	/**
	 * 
	 * @param gameController
	 */
	public GUIObserver(Controller gameController) {
		this.gameController = gameController;
	}

	/**
	 * Tells the game controller what method to tell the board to call.
	 * @param KeyEvent e
	 * 			the key pressed
	 */
	public void keyPressed(KeyEvent e) {	
		if(e.getKeyCode() == KeyEvent.VK_LEFT) {
			gameController.moveLeft();
		}
		else if(e.getKeyCode() == KeyEvent.VK_RIGHT) {
			gameController.moveRight();
		}
		else if(e.getKeyCode() == KeyEvent.VK_UP) {
			gameController.moveUp();
		}
		else if(e.getKeyCode() == KeyEvent.VK_DOWN) {
			gameController.moveDown();
		}
	}
}